#ifndef SYM__H__
#define SYM__H__

#include "op-list.h"

typedef struct Type_* Type;
typedef struct FieldList_* FieldList;
struct Type_{
    enum{BASIC,ARRAY,STRUCTURE} kind; 
    size_t size,has_fa;
    union {
        int basic;
        struct{Type elemnt;int size;}array;
        FieldList structure;
    }u;
};
extern Type Type_int,Type_float,Type_error;

struct FieldList_{
    char * name;
    Type type;
    FieldList nxt;
};

typedef struct TypeList_ * TypeList;
struct TypeList_{
    Type type;
    TypeList nxt;
};

typedef struct sym_unit_* sym_unit;
struct sym_unit_{
    char * name;
    enum{var,structdef,func} kind;
    int dep,valid;
    Operand xx;
    Type type;
    TypeList arg;
    sym_unit nxt1,nxt2;
};

void sym_pre_work();
extern int error_no;
sym_unit sym_insert(char * name,int kind,Type type,TypeList arg,int dep,int valid);
void sym_erase(sym_unit start);
Type arraytype_build(Type element,int size);
Type struct_build(Type old,char * subname,Type subelemt);
int undef_func_detect();
sym_unit sym_find(const char * name);
TypeList typeListBuild(Type type,TypeList nxt,int def);
int cmp_type(Type a,Type b);
int cmp_arg(TypeList a,TypeList b);

#endif
